<?php
/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-12-22
 * Time: 8:56
 */

/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-12-17
 * Time: 15:44
 */

namespace app\common\model;

use think\Db;
use think\Model as ThinkModel;

//银行列表模型
class Roomappointment extends ThinkModel
{
    protected $name = 'qt_room_appointment';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;

    public function getlist($engineer_id, $page, $limit)
    {
        $list = $this
            ->where('engineer_id',$engineer_id)
            ->where('status','1')
            ->page($page, $limit)
            ->select()
            ->each(function ($item) {
                $item['room_name'] =Room::where('id',$item['room_id'])->value('name');
                $item['project_name'] =Project::where('id',$item['project_id'])->value('name');
                $item['created_time'] =ST($item['created_time']);
                $item['time'] =ST($item['time']);
                return $item;
            });
        return $list;
    }

    /**
     * 获取技师预约数量
     * @param $engineer_id
     * @return Roomappointment
     */
    public function getCount($engineer_id)
    {
        $count= $this
            ->where('engineer_id',$engineer_id)
            ->where('status','1')
            ->count();
        return $count;
    }

}